/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package CCPVSimulationPackage;

import GISPackage.Region;
import GISPackage.Regions;

import GUIUtilities.CoalitionUtilities;
import GUIUtilities.ListUtilities;
import SocialMatrixPackage.SocialMatrix;
import ccpv.FileManager;
import ccpv.Person;
import ccpv.RunTimeSettings;
import ccpv.Utilities;
import java.io.File;
import java.io.IOException;
import java.util.List;
import multiarray.MultiArray;
import multiarray.RecursiveAccess;
import solver.Results;

/**
 *
 * @author Heather
 */
public class LeosSimTest
{



  /**
   * @param args the command line arguments
   */
  public static void main(String[] args)
  {
    // TODO code application logic here
    Regions regions = new Regions();

    try
    {
      regions.loadStuctureVariables(new File("c:/CCPV Data/all structure variables.csv"));
    } catch (IOException e)
    {
      System.out.println("bah humbug");
    }

    Region Indonesia = null;
    for (Region r : regions.regions)
    {
      if (r.name.equals("Indonesia"))
      {
        Indonesia = r;
      }
    }
    if (Indonesia == null)
    {
      System.out.println("NULL!");
    }
    else
    {

      // CCPVSimulationIteration runs your coalition function in its constructor
      CCPVSimulationIteration sim = new CCPVSimulationIteration("c:/CCPV Data/tests/indoformat.txt", Indonesia);

      // this is how to get all the partitions returned by your coalition model
      List<List<List<int[]>>> partitions = sim.getAllPartitions();
      // this is just picking the first partition
      List<List<int[]>> chosenPartition = partitions.get(0);
      // run conflict runs roberts conflict model and returns what it found.  it also sets a variable in
      // CCPVSimulationIteration that stores the results
      Results r = sim.runConflict(chosenPartition);
      System.out.println("partition$$$$: ");
      System.out.println(CoalitionUtilities.getPartitionString(chosenPartition));
      
      // let's store the coherence before we call your model
      MultiArray<MultiArray<Double>> preCoherenceAltruism = sim.getSimPop().getAltruismFromPersonsAsDoubles();
      sim.runCoherence();
      MultiArray<MultiArray<Double>> postCoherenceAltruism = sim.getSimPop().getAltruismFromPersonsAsDoubles();

      // printing the altruisms
      // stupid change
      System.out.println("********* PRE COHERENCE ALTRUISMS START *************");
      System.out.println(CoalitionUtilities.getAltruismAsDoublesPrintString(preCoherenceAltruism));
      System.out.println("********* PRE COHERENCE ALTRUISMS END   *************");

      System.out.println("********* POST COHERENCE ALTRUISMS START *************");
      System.out.println(CoalitionUtilities.getAltruismAsDoublesPrintString(postCoherenceAltruism));
      System.out.println("********* POST COHERENCE ALTRUISMS END   *************");
    }

  }
}
